Skip to content

fix(parser): extractConfidence reads the last CONFIDENCE marker - #7

Merged
marceloceccon merged 1 commit into
mainfrom
fix/extract-confidence-last-marker
Nov 21, 2026
Merged

marceloceccon merged 1 commit into
mainfrom
fix/extract-confidence-last-marker

Conversation

@marceloceccon

Copy link
Copy Markdown
Member

What changed

extractConfidence now returns the value of the last confidence: marker followed by digits (case-insensitive), instead of the first marker. A marker without digits, such as "Confidence: high", is skipped rather than returning 50. The default (50 when no marker has digits) and clamping to 0–100 are unchanged.

extractTrailingConfidence, added in the unreleased 0.13.0 and already imported by Roundtable's main, stays as a deprecated alias of extractConfidence. That way it doesn't matter in which order the three repos land or release.

The 0.13.0 CHANGELOG and README are updated; the version stays 0.13.0, since nothing is published yet.

Why

You approved this as a follow-up to #6.

The protocol asks for the score on the final line (CONFIDENCE: [number 0-100]), but the parser took the first hit:

  • Preview wins: "I'd put CONFIDENCE: 40 at first … CONFIDENCE: 64" scored 40.
  • Inline mention scores 50: "Confidence: high in the approach … CONFIDENCE: 80" scored 50, because the first hit had no digits.

Roundtable always used last-match semantics. That mismatch was half of what blocked moving Roundtable's CVP onto run(); only the 1-seat allowance remains.

Behaviour change: ConsensusEngine.run() scores change for responses that mention "confidence:" before their trailing line. Responses with a single trailing marker score exactly as before.

How it was verified

  • Core: npm run typecheck, npm test (261 tests) and npm run build pass on Node 24, and the tests pass on Node 20.20.2 [executed].
  • Tests:
    • The one existing test that pinned first-occurrence is inverted. Its comment claimed Roundtable's parser takes the first match; Roundtable's parser takes the last.
    • New parser tests cover the last marker winning and digit-less markers being skipped.
    • A new engine-level test checks that run() scores the trailing line when a response first says "Confidence: high" or previews a number.
    • The alias is the same function.
  • Mutation check: reverting to first-marker parsing fails 5 tests [executed].
  • Downstream: against a tarball of this branch, Roundtable main passes its 622 tests, including its own "picks the LAST CONFIDENCE marker" test. ai-consensus-mcp main typechecks and passes its 656 tests [executed].

What is left

  • Parser: extractJudgeConfidence still takes the first JUDGE_CONFIDENCE: marker. It's the same pattern but was outside the approved change; flipping it is a one-line follow-up if wanted.
  • Cleanup after 0.13.0 ships:
    • Roundtable can switch to extractConfidence, after which the alias can be removed in a later minor.
    • ai-consensus-mcp's normalize.ts header comment still says "first confidence: hit".

…digits

The protocol puts the score on the final line, but extractConfidence
took the first "confidence:" hit: an earlier preview captured the score,
and an inline "Confidence: high" made the whole response score 50 even
with a valid trailing CONFIDENCE line. It now returns the last marker
followed by digits (Roundtable's semantics); markers without digits are
skipped. Default 50 and clamping are unchanged.

This changes ConsensusEngine.run() scores for responses that mention
"confidence:" before their trailing line. The existing test that pinned
first-occurrence (with a comment misstating Roundtable's parser) is
inverted; new parser and engine-level tests cover the trailing rule.

extractTrailingConfidence (added in the unreleased 0.13.0, already used
by Roundtable's main) stays as a deprecated alias of extractConfidence,
so the order in which the repos land or release does not matter.
@marceloceccon
marceloceccon merged commit 3344d9f into main Nov 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant